package com.ttt.util;

import java.applet.Applet;
import java.applet.AudioClip;
import java.io.File;
import java.io.IOException;

public class MusicUtil {
    private static AudioClip start;
    private static AudioClip atk;
    private static AudioClip boom;
    private static AudioClip bomb;
    private static AudioClip bgm;
    //装载音乐资源
    static {
        try{
            //引号里面是音乐文件所在的相对路径
            start = Applet.newAudioClip(new File("music/start.wav").toURL());
            atk = Applet.newAudioClip(new File("music/atk.wav").toURL());
            boom = Applet.newAudioClip(new File("music/boom.wav").toURL());
            bomb = Applet.newAudioClip(new File("music/bomb.wav").toURL());
            bgm = Applet.newAudioClip(new File("C:\\Users\\a3330531971\\Desktop\\small game\\atomic tank\\music/bgm_angel").toURL());
        }catch (IOException e){
            e.printStackTrace();
        }
    }

    public static void playStart(){
        start.play();//播放音频
    }
    public static void playAtk(){
        atk.play();//播放音频
    }
    public static void playBoom(){
        boom.play();//播放音频
    }
    public static void playBomb(){
        bomb.play();//播放音频
    }
    public static void playBgm(){
        bgm.play();//播放音频
    }

}
